home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
-
- public class BounceItem extends Applet implements Runnable {
- boolean images_initialized = false;
- BounceImage[] images;
- boolean time_to_die;
- AudioClip music;
- AudioClip[] sounds;
- Image[] bounceimages;
-
- void makeImages(int var1) {
- this.bounceimages = new Image[8];
-
- for(int var2 = 1; var2 <= 8; ++var2) {
- this.bounceimages[var2 - 1] = ((Applet)this).getImage(((Applet)this).getCodeBase(), "images/jon/T" + var2 + ".gif");
- }
-
- this.images = new BounceImage[var1];
-
- for(int var3 = 0; var3 < var1; ++var3) {
- BounceImage var4 = this.images[var3] = new BounceImage(this);
- var4.move(1.0F + (float)var4.width * 0.8F * (float)(var3 % 3) + (float)(var3 / 3) * 0.3F * (float)var4.width, (float)var4.height * 0.3F + (float)(var3 % 3) * 0.3F * (float)var4.height);
- }
-
- this.sounds = new AudioClip[4];
- this.sounds[0] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), "audio/ooh.au");
- this.sounds[1] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), "audio/ah.au");
- this.sounds[2] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), "audio/dah.au");
- this.sounds[3] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), "audio/gong.au");
- this.music = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), "audio/spacemusic.au");
- }
-
- public void run() {
- try {
- if (this.images == null) {
- System.out.println("Making images ...");
- this.makeImages(4);
- }
-
- if (this.music != null) {
- this.music.loop();
- }
-
- long var1 = System.currentTimeMillis();
-
- while(!this.time_to_die) {
- long var6 = System.currentTimeMillis();
- long var8 = var6 - var1;
- boolean var10 = false;
- Dimension var11 = ((Component)this).size();
-
- for(int var5 = 0; var5 < this.images.length; ++var5) {
- BounceImage var12 = this.images[var5];
- var12.step(var8);
- if ((double)var12.Vy > 0.05 || (double)(-var12.Vy) > 0.05 || var12.y + (float)var12.width < (float)(var11.height - 10)) {
- var10 = true;
- }
- }
-
- if (!var10 && this.images.length != 0) {
- for(int var17 = 0; var17 < this.images.length; ++var17) {
- BounceImage var18 = this.images[var17];
- var18.Vx = (float)Math.random() / 4.0F - 0.125F;
- var18.Vy = -((float)Math.random()) / 4.0F - 0.2F;
- var18.Vr = 0.05F - (float)Math.random() * 0.1F;
- }
-
- if (this.sounds[3] != null) {
- this.sounds[3].play();
- }
- }
-
- ((Component)this).repaint();
- var1 = var6;
-
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var15) {
- return;
- }
- }
-
- } finally {
- if (this.music != null) {
- this.music.stop();
- }
-
- }
- }
-
- public void init() {
- Dimension var1 = ((Component)this).size();
- if (var1.width <= 100 || var1.height <= 100) {
- ((Applet)this).resize(500, 300);
- }
-
- }
-
- public void start() {
- this.time_to_die = false;
- (new Thread(this)).start();
- }
-
- public void stop() {
- this.time_to_die = true;
- this.music.stop();
- }
-
- public void paint(Graphics var1) {
- Dimension var2 = ((Component)this).size();
- var1.setColor(Color.gray);
- var1.drawRect(0, 0, var2.width - 1, var2.height - 1);
- if (this.images != null) {
- for(int var3 = 0; var3 < this.images.length; ++var3) {
- if (this.images[var3] != null) {
- this.images[var3].paint(var1);
- }
- }
- }
-
- }
- }
-